let multer  = require('multer')
let storage = multer.diskStorage({
    destination: function (req, file, cb) {
      cb(null, './public/uploads/')
    },
    filename: function (req, file, cb) {
        // 切割得到后缀名
        let fileArr = file.originalname.split(".");
        let extname = fileArr[fileArr.length-1];
      cb(null, file.fieldname + '-' + Date.now()+"."+extname)
    }
  })
   
let upload = multer({ storage: storage })

module.exports = upload